package com.ktjy;

import dao.BeanDaoMySqlImpl;
import entity.Bean;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class BeanText {
//    shangji3
    @Test
    public void BeanText() {
        ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        Bean bean = (Bean) context.getBean("num1");
        Bean bean1 = (Bean) context.getBean("num2");
        BeanDaoMySqlImpl beandao=(BeanDaoMySqlImpl)context.getBean("num3");

        beandao.insert(bean);
        beandao.insert(bean1);
    }
//    上机2、5
    @Test
    public void BeanText2() {
        ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        Bean bean = (Bean) context.getBean("Bean");
        Bean bean1 = (Bean) context.getBean("Bean1");
        bean.num();
        bean1.num();
    }
}